package org.uwrfidlab.nfc;

import android.os.Bundle;
import android.app.Activity;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.util.Log;
import android.widget.TextView;

public class AboutActivity extends Activity {
        private static final String TAG = "About";

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_about);

                
            String version = getVersionNumber();
            String name = getApplicationName();

            setTitle(getString(R.string.about_title, name));
                
            TextView text = (TextView)findViewById(R.string.about_text);
            text.setText(getString(R.string.about_text, version));
        }
        

        private String getVersionNumber() {
                String version = "?";
                try {
                        PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
                        version = pi.versionName;
                } catch (PackageManager.NameNotFoundException e) {
                        Log.e(TAG, "Package name not found", e);
                };
                return version;
        }
        

        private String getApplicationName() {
                String name = "?";
                try {
                        PackageInfo pi = getPackageManager().getPackageInfo(getPackageName(), 0);
                        name = getString(pi.applicationInfo.labelRes);
                } catch (PackageManager.NameNotFoundException e) {
                        Log.e(TAG, "Package name not found", e);
                };
                return name;
        }

}